/**
 * 时间戳转换为日期格式字符串
 * @param {string} value
 * @param {string} lang  // 显示
 * @param {string} format // 格式
 * @param {string} mark  // 符号
 * @returns {string}
 */
export function timeFmt(value, lang, format, mark) {
	if (!value) {
		return ''
	}
	// var valuenew=value.toString().replace(/-/g, '/')
	let hmsMark = ':'
	if (mark === '.') {
		hmsMark = '.'
	}
	let result = ''

	let date = new Date(value)

	const y = date.getFullYear()
	let MM = date.getMonth() + 1
	MM = MM < 10 ? ('0' + MM) : MM
	let d = date.getDate()
	d = d < 10 ? ('0' + d) : d
	let h = date.getHours()
	h = h < 10 ? ('0' + h) : h
	let m = date.getMinutes()
	m = m < 10 ? ('0' + m) : m
	let s = date.getSeconds()
	s = s < 10 ? ('0' + s) : s
	if (lang == 'CN') {
		return y + '年' + MM + '月' + d + '日'
	} else {
		switch (format) {
			case 'mm':
				result = MM
				break
			case 'ym':
				result = y + mark + MM
				break
			case 'hm':
				result = y + mark + MM + mark + d + ' ' + h + hmsMark + m
				break
			case 'hms':
				result = y + mark + MM + mark + d + ' ' + h + hmsMark + m + hmsMark + s
				break
			default:
				result = y + mark + MM + mark + d
				break
		}
		return result
	}
}
